Custom Groovy Code For Pre-Post Process CancelTransaction

This topic describes how custom groovy code can be used to pre-process and post-process a truck transaction while canceling a truck transaction.

In N4, go to the Administration > System > Groovy Plug-ins view and add the following (sample) code as a new Groovy Plug-in. Note that this is an example code and may not cover all the errors at this point:

import com.Navis.road.RoadEntity;

import com.Navis.road.business.model.TruckTransaction;

import com.Navis.road.business.atoms.TranStatusEnum;

public class CancelDMTransactionInterceptor{

  /**

   * This method is called just before cancelling a truck transaction.

   * @param inParameters contains the truck transaction that is cancelled.

   */

public void preProcessCancelTransaction(Map inParam){

def transaction = (TruckTransaction) inParam.get("TruckTransaction");

println("Executing CancelDMTransactionInterceptor.preProcessCancelTransaction method");

println(transaction.getTranStatus());

   }

   /**

   * This method is called just after a truck transaction is cancelled.

   * @param inParameters contains the truck transaction that is cancelled.

   */

   public void postProcessCancelTransaction(Map inParam) {

def transaction = (TruckTransaction) inParam.get("TruckTransaction");

println("Executing CancelDMTransactionInterceptor.postProcessCancelTransaction method");

println(transaction.getTranStatus());

   }

}